package com.edu.service.Impl;

import com.edu.dao.UserDao;
import com.edu.dao.impl.UserDaoImpl;
import com.edu.entity.User;
import com.edu.service.UserService;

public class UserServiceImpl implements UserService {
    UserDao userDao=new UserDaoImpl();

    @Override
    public int insert(User user) {
        int num=userDao.insert(user);
        return num;
    }

    @Override
    public User select(String userName, String userPW) {
        User user =userDao.selectByUsername(userName);
        if(user==null){
            System.out.println("账号不存在的user");
            return user;
        }
        User user1=userDao.select(userName,userPW);
        if(user1==null){
            System.out.println("密码不存在的user");
            User user2=new User();
            user2.setUserId(-1);
            return user2;
        }
        return user1;
    }
}
